<script>
	
	export default {
		globalData: {
		            url: 'https://zhangjie.jdmuguzhid.com',
		            static:'https://zhangjie.jdmuguzhid.com/static/images/yztang',
					version:'1.3.1.0'
		        },
		onLaunch: function() {
			// console.log('App Launch')
			// #ifdef APP-PLUS
			plus.runtime.getProperty(plus.runtime.appid, function(widgetInfo) {
				console.log(widgetInfo);
				uni.request({  
					url: 'https://zhangjie.jdmuguzhid.com/wechat_update_version',
					data: {
						version: widgetInfo.version,
						name: widgetInfo.name
					},
					success: (res) => {  
						var data = res.data;  
						console.log(res);
						if(data.update!=0)
						{
							uni.showModal({ //提醒用户更新
								title: "更新提示",  
								content: data.note,  
								success: (res) => {  
									if (res.confirm) 
									{
										if (data.update==1)
										{
											plus.runtime.openURL(data.wgtUrl);  
										}
										if(data.update==2)
										{
											uni.downloadFile({
												url: data.wgtUrl,  
												success: (downloadResult) => {
													if (downloadResult.statusCode === 200) 
													{  
														plus.runtime.install(downloadResult.tempFilePath, {  
															force: false  
														}, function() {  
															console.log('install success...');  
															plus.runtime.restart();  
														}, function(e) {  
															console.error('install fail...');  
														});  
													}  
												}  
											});
										}
									}  
								}  
							})
						}
					}
				});  
			});
			// #endif
		},
		onShow: function() {
			// console.log('App Show')
		},
		onHide: function() {
			// console.log('App Hide')
		}
	}
</script>

<style>
	/*每个页面公共css */
</style>
